package ${package}.${moduleName}.service.impl;

import ${package}.${moduleName}.mapping.${BeanName}Mapping;
import ${package}.${moduleName}.model.${BeanName}Model;
import ${package}.${moduleName}.mapper.${BeanName}Mapper;
import ${package}.${moduleName}.request.${BeanName}FormReq;
import ${package}.${moduleName}.request.${BeanName}QueryReq;
import ${package}.${moduleName}.response.${BeanName}Rsp;
import ${package}.${moduleName}.service.I${BeanName}Service;
import com.github.pagehelper.PageHelper;
import com.qigio.api.util.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ${tableComment}
 *
 * @author ${author} ${email}
 */
@Service
@RequiredArgsConstructor
public class ${BeanName}ServiceImpl extends BaseServiceImpl<${BeanName}Mapper, ${BeanName}Model> implements I${BeanName}Service {

    private final ${BeanName}Mapping ${beanName}Mapping;

    @Override
    public Page<${BeanName}Rsp> page${BeanName}Rsp(int page, int size, ${BeanName}QueryReq req) {
        PageHelper.startPage(page, size);
        return new Page<${BeanName}Rsp>(mapper.list${BeanName}Rsp(req));
    }

    @Override
    public List<${BeanName}Rsp> list${BeanName}Rsp(${BeanName}QueryReq req) {
        return mapper.list${BeanName}Rsp(req);
    }

    @Override
    public ${BeanName}Rsp get${BeanName}Rsp(${BeanName}QueryReq req) {
        return mapper.get${BeanName}Rsp(req);
    }

    @Override
    public boolean addFormReq(${BeanName}FormReq req) {
        ${BeanName}Model model = ${beanName}Mapping.toModel(req);
        int insert = mapper.insertSelective(model);
        return 1 == insert;
    }

    @Override
    public boolean updateFormReq(${BeanName}FormReq req) {
        ${BeanName}Model model = ${beanName}Mapping.toModel(req);
        int insert = mapper.updateByPrimaryKeySelective(model);
        return 1 == insert;
    }
}